Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • collect table header merging/centering| after stcox

    Hello all:

    I want to merge/center the repeating header cells for Uni-variable and Multi-variable statistics in the header and add a single bottom border for just those header rows for a publication style depiction after 4 Cox models for the three variable (age, No. of monosomies and smotl1). Both are levels of dim "uvmodel' in the code below.
    This clearly involves some fortags or remap but I am stumbling at this step. I have included the -stset- and the -collect- codes. Sorry again for the long-winded post.

    This is as far as I got:

    stset docens, fail(dead) origin(time dodx) ///
    enter(time dodx) ///
    exit(time dodx + 24 * 30.455) ///
    scale(30.455)

    // Table of mva model

    lab var age70 "Age at Dx."
    lab var monomore "No. of monosomies"

    collect clear
    collect create mv1
    collect _r_b _r_ci: stcox i.age70 i.monomore i.smotl1
    collect _r_b _r_ci: stcox i.age70
    collect _r_b _r_ci: stcox i.monomore
    collect _r_b _r_ci: stcox i.smotl1


    collect style showbase all

    // Number formatting
    collect style cell, nformat(%5.2f)
    collect style cell result[_r_ci], sformat("[%s]") cidelimiter(", ")
    collect style cell border_block, border(right, pattern(nil))
    collect preview

    //Var and label name formatting

    collect stars _r_p 0.01 "***" 0.05 "** " 0.1 "* " 1 " ", attach(_r_b)
    collect notes : "*** p<.01, ** p<.05, * p<.1"
    collect style cell result[_r_b], halign(left) margin(left, width(10))
    collect style row stack, nobinder // indents the factor from variable name

    collect levels cmdset
    collect addtags uvmodel[2], fortags(cmdset[2 3 4]) // tags 3 univariate to 1 column
    collect addtags uvmodel[1], fortags(cmdset[1])
    collect levelsof uvmodel

    collect layout (colname)(uvmodel#result)

    //Align CI to the left and relabel some
    collect style cell result[_r_ci], halign(left)
    collect style cell result[_r_b], halign(left)

    collect label levels uvmodel 1 "Multi-variable" 2 "Uni-variable"
    collect label levels age70 0 "<=70 yrs" 1 ">70 yrs", modify
    collect label levels monomore 0 "0-1" 1 "2+", modify
    collect label dim age70 "Age at Dx.", modify
    collect label levels result _r_b "HR", modify
    collect label levels result _r_ci "95% CI", modify

    collect preview


    ------------------------------------------------------------------------------------------------------------
    Uni-variable Uni-variable Multi-variable Multi-variable
    HR 95% CI HR 95% CI
    -----------------------------------------------------------------------------------------------------------
    Age at Dx.
    <=70 yrs 1.00 1.00
    >70 yrs 1.45* [0.97, 2.17] 1.32 [0.84, 2.07]
    No. of monosomies
    0-1 1.00 1.00
    2+ 1.65** [1.08, 2.54] 1.85*** [1.17, 2.92]
    TP53 domain
    Non-L1/S/H2 Mutation 1.00 1.00
    L1/S/H2 Mutation 1.95*** [1.25, 3.02] 1.75** [1.10, 2.78]
    -------------------------------------------------------------------------------


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int dodx long dead int docensor float(age70 monomore smotl1)
    21348 1 21798 0 1 1
    21916 1 22125 1 0 1
    20301 1 20444 0 1 0
    21829 1 22099 1 0 1
    22095 1 22171 1 0 0
    22287 1 22667 1 1 0
    21366 1 21544 0 1 1
    22203 1 22509 0 . 0
    20328 1 21806 0 1 0
    20816 1 21205 0 1 0
    21962 1 22162 1 1 1
    21279 1 21314 0 1 1
    22530 0 22658 0 . 1
    20508 1 20601 1 0 0
    22517 1 22760 1 0 0
    20171 1 20377 0 1 0
    21360 1 21442 0 . 0
    21455 1 21901 0 1 0
    21334 1 21715 0 1 0
    21780 1 21920 1 0 0
    20969 1 21010 1 0 0
    21992 1 22078 1 1 1
    21511 1 22123 1 0 0
    22285 1 22368 1 0 1
    21500 1 21734 0 1 0
    21856 1 22885 1 0 0
    21419 1 21609 0 1 1
    20159 1 20464 0 . 0
    20433 1 20580 0 . .
    22655 1 22741 1 1 0
    19540 1 20939 0 0 0
    18226 1 20612 0 0 0
    21124 1 21729 0 0 0
    21082 1 21353 1 0 0
    21719 1 21973 0 1 0
    21304 1 21403 0 0 1
    22434 1 22496 1 1 1
    21105 0 22890 1 0 1
    22977 0 22998 1 0 0
    21738 0 22977 0 0 0
    20789 1 20885 0 1 0
    22140 0 22998 1 0 1
    19991 1 20907 1 1 0
    21797 1 21806 0 0 0
    20083 1 20116 0 1 0
    20109 1 20541 0 1 0
    21931 1 22424 0 0 0
    20137 1 20673 1 0 .
    20137 1 20946 0 0 0
    21531 1 21829 0 1 1
    20280 1 20868 0 1 0
    20285 1 20334 1 1 0
    20293 1 20698 1 1 0
    20270 1 21455 0 . 0
    20558 1 20667 1 1 .
    20887 1 22427 0 0 0
    21850 1 22133 0 0 1
    20362 1 20399 0 1 .
    20419 1 20534 0 0 1
    20458 1 20518 1 0 0
    21342 1 22437 1 0 0
    20578 1 20739 0 0 1
    20671 1 20721 1 1 0
    20773 1 21273 1 1 0
    20773 1 20852 0 1 1
    21601 1 21634 1 1 1
    20816 1 21047 0 0 0
    20850 1 21043 0 1 1
    20885 1 21139 0 1 1
    20730 1 21948 0 0 0
    20936 1 21397 0 0 0
    20969 1 21267 0 . 0
    21062 1 21111 1 1 1
    21173 1 21267 0 0 1
    21158 1 21203 0 1 0
    21249 1 21428 1 1 0
    21249 1 21595 1 . 0
    21922 1 21962 1 0 .
    21271 1 21588 0 0 .
    21293 1 21713 0 1 1
    22811 0 22994 0 1 0
    21346 1 22359 1 1 1
    21093 1 21443 0 0 0
    21798 1 21901 0 1 0
    22404 1 22488 0 0 1
    21764 1 21841 0 . 0
    21411 1 21543 1 . 1
    21567 1 21974 1 0 1
    21444 1 21608 0 1 0
    21850 1 21933 0 0 0
    21626 0 21740 1 0 0
    21651 1 21817 1 0 1
    21366 1 21948 0 1 0
    21759 1 21791 0 0 1
    22271 0 22894 0 0 0
    21900 1 22027 1 1 1
    22371 1 22829 0 1 0
    22001 1 22308 1 0 0
    21993 1 22344 0 1 0
    22286 1 22367 1 1 1
    end
    format %tdnn/dd/CCYY dodx
    format %tdnn/dd/CCYY docensor
    label values dead deadlab
    label def deadlab 0 "Alive", modify
    label def deadlab 1 "Dead", modify
    label values smotl1 palab
    label def palab 0 "Non-L1/S/H2 Mutation", modify
    label def palab 1 "L1/S/H2 Mutation", modify

  • #2
    Sorry...I just figured it out. This code below did it. Hopefully, this will be useful for folks creating a standard Cox template like this journals. I am slowly trudging through the -collect- in the PDF manual. Definitely worth investing the time.

    collect style column, dups(center) extraspace(2)

    Comment

    Working...
    X